﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Activities;
using Vowei.Core.Models;

namespace Vowei.Workflows.Tickets
{

    public sealed class WaitTaskBeAccepted : NativeActivity<bool>
    {
        public InArgument<Task> Task { get; set; }

        protected override void Execute(NativeActivityContext context)
        {
            var task = Task.Get(context);
            var bmName = BookmarkNameManager.CreateBookmarkName(task);
            context.CreateBookmark(bmName, OnTaskAccepted);
        }

        void OnTaskAccepted(NativeActivityContext context, Bookmark bookmark, object value)
        {
            bool accepted = (bool)value;
            context.SetValue(Result, accepted);
        }
    }
}
